package stu.day19_day24.day23;

import java.util.Arrays;
import java.util.Scanner;

public class hw4 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int num1 = Integer.parseInt(sc.nextLine());
        String[] str = sc.nextLine().split(" ");

        int[][] arr = new int[str.length][2];
        for (int i=0;i<str.length;i++){
            arr[i][0] =Integer.parseInt( str[i].split("[:]")[0]);
            arr[i][1] =Integer.parseInt( str[i].split("[:]")[1]);
        }
        Arrays.sort(arr,(o1, o2) -> o1[0]-o2[0]);

        int left = 0;
        int right = arr.length;
        while (left<right){
            int mid = (left+right)/2;
            if(arr[mid][0]>=num1){
                right = mid;
            }else {
                left = mid+1;
            }
        }

        if((arr[left][0]-num1)>(num1-arr[left-1][0])){
            System.out.println(arr[left-1][1]);
        } else if ((arr[left][0]-num1)<(num1-arr[left-1][0])) {
            System.out.println(arr[left][1]);
        }else {
            double fu = (arr[left][1]+arr[left-1][1])/2.0;
            System.out.printf("%.2f%n",fu);
        }


    }
}
